package org.tabcap.workspace.gui.text.console;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JPanel;
import javax.swing.JScrollPane;

import org.tabcap.workspace.gui.text.TCTextArea;

public class TCConsole extends JPanel
{
	private static final long serialVersionUID = -119456594598973685L;
	
	protected TCTextArea textArea;
	public TCTextArea textArea() { return textArea; }
	public void addLine(String text) { textArea.append(text + "\n"); }
	public void addErrorLine(String text) { textArea.append("[ERROR]:" + text + "\n"); }
	public void clear() { textArea.setText(""); }

	public TCConsole()
	{
		setLayout(new BorderLayout());
		setMinimumSize(new Dimension(250, 75));
		
		textArea = new TCTextArea();
		textArea.setEditable(false);
		JPanel wrapper = new JPanel(new BorderLayout());
		wrapper.add(textArea, BorderLayout.CENTER);
		JScrollPane scrollPane = new JScrollPane(wrapper);
		scrollPane.setPreferredSize(new Dimension(350, 100));
		scrollPane.getVerticalScrollBar().setUnitIncrement(50);
		add(scrollPane, BorderLayout.CENTER);
	}
}